package com.sinohb.autonomousdriving_test;

import android.os.Bundle;
import android.view.WindowManager;
import android.widget.ImageButton;

import androidx.appcompat.app.AppCompatActivity;

import com.hb.sq3d.Viewer3D;

public class RendererActivity extends AppCompatActivity {
    private TestCase m_testCase;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_renderer);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        ImageButton modeBtn = findViewById(R.id.mode);
        modeBtn.setOnClickListener(view -> {
            if (modeBtn.getTag() == null) {
                modeBtn.setImageResource(R.mipmap.mode_dark);
                modeBtn.setTag(new Object());
            } else {
                modeBtn.setImageResource(R.mipmap.mode_light);
                modeBtn.setTag(null);
            }
            Viewer3D.switchDayNightMode(modeBtn.getTag() != null);
        });

        m_testCase = new TestCase(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        m_testCase.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        m_testCase.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        m_testCase.onDestroy();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finishAffinity();
        System.exit(0);
    }
}